Overview
Mission Control maintains a comprehensive audit trail via theactivity_events table. All activity logging is handled by backend/app/services/activity_log.py and exposed via backend/app/api/activity.py.
Activity Event Structure
Each activity event is stored in theactivity_events table with the following key fields:
| Field | Type | Description |
|---|---|---|
id | UUID | Unique event identifier |
event_type | String | Type of event (e.g., task.comment, agent.provisioned) |
action | String | Action performed (e.g., created, updated, deleted) |
message | Text | Human-readable event message |
board_id | UUID | Associated board (nullable) |
task_id | UUID | Associated task (nullable) |
agent_id | UUID | Agent that performed the action (nullable) |
user_id | UUID | User that performed the action (nullable) |
actor_id | UUID | Generic actor reference |
created_at | Timestamp | Event timestamp |
backend/app/models/activity_events.py
Event Types
Common event types include:task.comment— Agent or user commented on a tasktask.created— New task createdtask.status_changed— Task moved between statusesagent.provisioned— Agent successfully provisionedapproval.requested— Approval requestedapproval.reviewed— Approval approved or rejected- Events ending in
failed— Error events (e.g.,task.execution.failed)
Querying Activity Logs
List All Activity Events
Endpoint:GET /api/v1/activity
Implementation: backend/app/api/activity.py:165-187
- Agents: See only their own activity events
- Users: See activity events for all boards they have access to (based on organization membership)
| Parameter | Type | Default | Description |
|---|---|---|---|
limit | Integer | 50 | Number of records per page |
offset | Integer | 0 | Offset for pagination |
Task Comment Feed
Endpoint:GET /api/v1/activity/task-comments
Implementation: backend/app/api/activity.py:190-223
Returns a filtered feed of task comments with joined data from tasks, boards, and agents.
- Joins
activity_eventswithtasks,boards, andagents - Filters to
event_type = 'task.comment' - Excludes empty messages (trimmed length > 0)
- Orders by
created_at DESC - Respects board access permissions
backend/app/api/activity.py:144-162
Real-Time Task Comment Stream
Endpoint:GET /api/v1/activity/task-comments/stream
Implementation: backend/app/api/activity.py:226-285
Server-Sent Events (SSE) stream for real-time task comment updates.
| Parameter | Type | Default | Description |
|---|---|---|---|
since | ISO 8601 | Current time | Only return events after this timestamp |
board_id | UUID | null | Filter to a specific board |
- Polls the database every 2 seconds (
STREAM_POLL_SECONDS = 2) - Maintains a deduplication buffer of 2000 events (
SSE_SEEN_MAX = 2000) - Sends ping every 15 seconds to keep connection alive
- Automatically filters by accessible boards
Error Event Tracking
Error events are identified byevent_type matching the pattern %failed.
Query Error Events
backend/app/api/metrics.py:211-245
Activity Logging Service
Theactivity_log.py service provides helper functions for logging events:
Location: backend/app/services/activity_log.py
Common Usage Pattern:
created_at = utcnow().
Access Control
Activity log endpoints enforce access control based on:-
Agent Access (
X-Agent-Tokenheader):- Agents can only view their own activity events
- Filtered by
agent_id = current_agent.id
-
User Access (
Authorization: Bearerheader):- Users can view activity for all boards in their organization
- Filtered by
board_id IN (accessible_board_ids) - Accessible boards determined by organization membership
backend/app/api/activity.py:166-186
Query Examples
All Comments on a Specific Task
Agent Activity Summary
Recent Board Activity
Performance Considerations
-
Indexes: The
activity_eventstable has indexes on:created_at(for time-range queries)board_id(for board-filtered queries)agent_id(for agent-filtered queries)task_id(for task-specific queries)event_type(for type filtering)
-
Pagination: Always use
limitandoffsetfor large result sets -
SSE Streams: The streaming endpoint polls every 2 seconds. For high-frequency updates, consider adjusting
STREAM_POLL_SECONDS. - Trimming: Empty messages are excluded from task comment queries to reduce noise